package m.meiweitech.com.rocket.app

import android.content.Context
import com.jeremyliao.liveeventbus.LiveEventBus
import com.orhanobut.logger.AndroidLogAdapter
import com.orhanobut.logger.Logger
import com.tencent.mmkv.MMKV
import io.flutter.app.FlutterApplication
import io.flutter.embedding.engine.FlutterEngine
import m.meiweitech.com.rocket.BuildConfig
import m.meiweitech.com.rocket.util.BluetoothClientUtil
import m.meiweitech.com.rocket.helper.PipeHelper
import kotlin.properties.Delegates


/**
 * @author WEN
 * @Description:
 * @date 2020/11/1 21:42
 */
class App : FlutterApplication(){

    companion object {

        var CONTEXT: Context by Delegates.notNull()

        var flutterEngine: FlutterEngine by Delegates.notNull()

    }

    override fun onCreate() {
        super.onCreate()
        CONTEXT = this;
        sdkInitialized()
    }

    private fun sdkInitialized() {
        PipeHelper.initialize(CONTEXT)
        BluetoothClientUtil.invoke(this)
        Logger.addLogAdapter(object : AndroidLogAdapter() {
            override fun isLoggable(priority: Int, tag: String?): Boolean {
                return BuildConfig.DEBUG
            }
        })
        MMKV.initialize(this)
        LiveEventBus
            .config()
            .lifecycleObserverAlwaysActive(true)
    }

}